package gui.actions;

import javax.swing.JComponent;

import gui.GuiManager;
import gui.GuiManager.FramesEnum;
import gui.models.PlayModel;

public class PlayBackAction extends WorkerAction {
	
	private static final long serialVersionUID = 1L;
	private PlayModel model;

	public PlayBackAction(JComponent owner, PlayModel model) {
		super(owner);
		this.model = model;
	}

	@Override
	public boolean isAllowToRunOperation() {
		return true;
	}
	
	@Override
	public void runOperation() throws Exception {
		model.getPlayLogic().finishGame();
	}
	
	@Override
	public void operationSucceed() {
		GuiManager.switchFrame(FramesEnum.PREVIOUS_FRAME);		
	}
	
	@Override
	public void operationFailed(Exception e) {
		GuiManager.switchFrame(FramesEnum.PREVIOUS_FRAME);
	}	
	
}
